-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
out_forward plugin can set targets dynamically via service discovery plugin. #2541
Conversation
87a21da
to
d1294ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we create service_discovery helper for supporting create/configure/manage routines?
lib/fluent/plugin/sd_file.rb
Outdated
|
||
module Fluent | ||
module Plugin | ||
class SdFile < ServiceDiscovery |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use FileServiceDiscovery
better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
57d0ef0 fixed
lib/fluent/plugin/sd_file.rb
Outdated
) | ||
end | ||
rescue KeyError => e | ||
raise Fluent::ConfigError, e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, KeyError
's error message is not user friendly.
Adding more information is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added information about what config needs
61a05cd
b3f4ee905
lib/fluent/plugin/sd_static.rb
Outdated
|
||
module Fluent | ||
module Plugin | ||
class SdStatic < ServiceDiscovery |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StaticServiceDiscovery
is better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
57d0ef0 fixed
lib/fluent/plugin/sd_static.rb
Outdated
def configure(conf) | ||
super | ||
|
||
@services << ServiceDiscovery::Service.new(:static, @host, @port, @name, @weight, @standby, @username, @password, @shared_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this plugin support only one server unlike out_forward?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.. changed to be able to handle multiple services.
be04758
end | ||
end | ||
|
||
def select_node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
select_node
naming is ok?
This seems out_forward's one. select_service
is better than select_node
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. this is out_forward's name. changed to select_service
fixed 9883173 |
lib/fluent/plugin/out_forward.rb
Outdated
@@ -138,6 +139,10 @@ class ForwardOutput < Output | |||
config_param :weight, :integer, default: 60 | |||
end | |||
|
|||
config_section :service_discovery do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This define should be done via helper. See parser
helper implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed 54e8d53
# @param configurations [Hash] hash which must has discivery_service type and its configuration like `{ type: :static, conf: <Fluent::Config::Element> }` | ||
# @param load_balancer [Object] object which has two methods #rebalance and #select_service | ||
# @param custom_build_method [Proc] | ||
def create_service_discovery_manager(title, configurations:, load_balancer: nil, custom_build_method: nil, interval: 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
service_disovery_create_manager
is better to follow other plugin helpers.
helpers uses its name as function prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed 46e6e0c
@_plugin_helper_service_discovery_title = title | ||
@_plugin_helper_service_discovery_iterval = interval | ||
|
||
@discovery_manager = Fluent::PluginHelper::ServiceDiscovery::Manager.new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unlike other helpers, this helper doesn't allow multiple instance, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean multiple @dicovery_mangers
? if so, yes.
This manager instance should be one per output/input plugin. the manager has multiple sd plugins.
module Fluent | ||
module Plugin | ||
class ServiceDiscovery # already loaded | ||
DiscoveryMessage = Struct.new(:type, :service) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exposing this struct is needed? ServiceDiscovery.service_in/service_out
also looks good for me.
With this approach, we can move this implementation into service_discovery.rb
and users don't need to require additional file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed 4ba7c7a
@cosmo0920 Do you need to review this? You link this PR from elasticsearch plugin. |
I'm considering to use service discovery plugin in elasticsearch plugin.
Curently, no. The above link is just a note. |
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
add sd_file Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
if @rr is greater than the size of @weight_array by reducing weight_array number, node can be nil Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Finally merged :) |
@ganmacs Could you update fluentd document for service discovery plugin? |
Which issue(s) this PR fixes:
Fixes #756 ?
What this PR does / why we need it:
I Added service_discovery plugin which sets config of servers in out_forwardy dynamically.
In this PR, I supported
sd_file
plugins andsd_static
plugin.sd_file checks the specified file periodically and update its targets.
sd_static is same as
<server>
configuration. So the following configurations are completely the same.Docs Changes:
Needed for service discovery plugin.
Release Note:
out_forward plugin can set targets dynamically via service discovery plugin.